
<template>
  <h1>通过store对象直接调用</h1>
  <h2>年龄: {{age}}</h2>
  <h3>名字: {{name}}</h3>
  <button @click="people_store.setPeopleInfo('问问','18')">点我改变people1</button>
  <button @click="people_store.setPeopleInfoObj({name:'文文',age:19})">点我改变people2</button>
  <hr>
  <h1>storeToRefs映射为本地函数</h1>
  <button @click="setPeopleInfo('红红','20')">函数改变</button>
  <button @click="z_setPeopleInfoObj({name:'红红2',age:'202'})">函数别名改变</button>
</template>
<script setup>
import { storeToRefs} from 'pinia'
import { usePeopleStore2 } from "../stores/usePeopleStore2";

// 1.0 获取对象实例 这种是不可以修改的
let people_store = usePeopleStore2()

// 结构出来
let {age,name} = storeToRefs(people_store)
let {
  setPeopleInfo,
  setPeopleInfoObj:z_setPeopleInfoObj,// 别名
} = people_store
</script>
